//
//  FiltratePriceAreaCell.m
//  pmm
//
//  Created by WTFSSD on 2017/7/28.
//  Copyright © 2017年 WTFSSD. All rights reserved.
//

#import "FiltratePriceAreaCell.h"


@interface FiltratePriceAreaCell()<UITextFieldDelegate>

@property(nonatomic,strong)UITextField * lowTextField;
@property(nonatomic,strong)UITextField * heighTextField;

@end
@implementation FiltratePriceAreaCell

-(void)initSubViews{
    [super initSubViews];


       UITextField * lowTextField = [HMTextField createTextFieldWithText:@"" andpLlaceholder:@"最低价" andTextColor:[UIColor blackColor] andBgColor:RGB(237, 241, 245) andFont:[UIFont fontWithName:default_fontname size:autoScaleW(13)] andTextAlignment:NSTextAlignmentCenter andTextFieldViewMode:UITextFieldViewModeWhileEditing];
       lowTextField.borderStyle = UITextBorderStyleRoundedRect;
        lowTextField.delegate = self;
       [lowTextField addTarget:self action:@selector(textFieldTextChange:) forControlEvents:UIControlEventEditingChanged];
        lowTextField.layer.borderColor = RGB(237, 241, 245).CGColor;
        lowTextField.keyboardType = UIKeyboardTypeNumbersAndPunctuation;
        [self.contentView addSubview:lowTextField];

        self.lowTextField = lowTextField;


       UITextField * heighTextField = [HMTextField createTextFieldWithText:@"" andpLlaceholder:@"最高价" andTextColor:[UIColor blackColor] andBgColor:RGB(237, 241, 245) andFont:[UIFont fontWithName:default_fontname size:autoScaleW(13)] andTextAlignment:NSTextAlignmentCenter andTextFieldViewMode:UITextFieldViewModeWhileEditing];

        heighTextField.borderStyle = UITextBorderStyleRoundedRect;
        heighTextField.delegate = self;
        [heighTextField addTarget:self action:@selector(textFieldTextChange:) forControlEvents:UIControlEventEditingChanged];
        heighTextField.layer.borderColor = RGB(237, 241, 245).CGColor;
        heighTextField.keyboardType = UIKeyboardTypeNumbersAndPunctuation;

        [self.contentView addSubview:heighTextField];
        self.heighTextField = heighTextField;
        
        UIView * line = [[UIView alloc] initWithFrame:CGRectZero];
        line.backgroundColor = RGB(196, 198, 200);
        [self.contentView addSubview:line];

    //
        self.hyb_lastViewInCell = self.lowTextField;

        
        [lowTextField mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.titleView.mas_bottom).offset(autoScaleH(10));
            make.left.equalTo(self.contentView.mas_left).offset(autoScaleW(10));
            make.width.mas_equalTo(autoScaleW(128));
            make.height.mas_equalTo(autoScaleH(26));

        }];
        
        [heighTextField mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(lowTextField.mas_top);
            make.width.mas_equalTo(autoScaleW(128));
            make.height.mas_equalTo(autoScaleH(26));

            make.left.equalTo(lowTextField.mas_right).offset(autoScaleW(60));
        }];
        
        [line mas_makeConstraints:^(MASConstraintMaker *make) {
            make.height.mas_equalTo(autoScaleW(1));
            make.left.equalTo(lowTextField.mas_right).offset(autoScaleW(5));
            make.right.equalTo(heighTextField.mas_left).offset(autoScaleW(-5));
            make.centerY.equalTo(heighTextField.mas_centerY);
        }];
    
    self.hyb_bottomOffsetToCell = 20;
}


-(void)textFieldTextChange:(UITextField*)textField{

    if (textField == self.lowTextField) {
        if (self.delegate&&[self.delegate respondsToSelector:@selector(FiltratePriceAreaCell:valueChangeWithLowPriceTextFiled:)]) {
            [self.delegate FiltratePriceAreaCell:self valueChangeWithLowPriceTextFiled:textField];
        }
    }else if (textField == self.heighTextField){
        if (self.delegate&&[self.delegate respondsToSelector:@selector(FiltratePriceAreaCell:valueChangeWithHeightPriceTextFiled:)]) {
            [self.delegate FiltratePriceAreaCell:self valueChangeWithHeightPriceTextFiled:textField];
        }
    }
}
@end
